package com.lqk.fnandroid

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner

class LifeCallback : LifecycleEventObserver {
    companion object {
        const val TAG = "生命周期"
    }

    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        when (event) {
            Lifecycle.Event.ON_CREATE -> {
                Log.d(TAG, "onStateChanged: OnCreate")
            }
            Lifecycle.Event.ON_START -> {
                Log.d(TAG, "onStateChanged: OnStart")
            }
            Lifecycle.Event.ON_RESUME -> {
                Log.d(TAG, "onStateChanged: OnResume")
            }
            Lifecycle.Event.ON_PAUSE -> {
                Log.d(TAG, "onStateChanged: OnPause")
            }
            Lifecycle.Event.ON_STOP -> {
                Log.d(TAG, "onStateChanged: OnStop")
            }
            Lifecycle.Event.ON_DESTROY -> {
                Log.d(TAG, "onStateChanged: OnDestroy")
            }
            Lifecycle.Event.ON_ANY -> {
                Log.d(TAG, "onStateChanged: OnAny")
            }
            else -> {

            }
        }
    }
}